﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlogModel.DAL
{
    public static class BlogDB
    {
        public static Blog GetBlogByUserName(string userName)
        {
            var foundUser = DB.Context.UserSet
                .FirstOrDefault(u => u.UserName == userName && !u.IsDeleted);

            return DB.Context.BlogSet
                .FirstOrDefault(b => b.UserId == foundUser.UserId && !b.IsDeleted);
        }
        public static Blog GetBlogOnUserId(int userId)
        {
            return DB.Context.BlogSet
                .FirstOrDefault(b => b.UserId == userId && !b.IsDeleted);
        }

        public static List<Blog> GetAllBlogs()
        {
            return DB.Context.BlogSet.Where(b => !b.IsDeleted).ToList();
        }
      
    }
}
